package com.yima.baseproj.module.app.student;

import com.yima.baseproj.aop.log.Logging;
import com.yima.baseproj.module.config.utils.ResultUtil;
import com.yima.baseproj.module.config.utils.ResultVo;
import com.yima.baseproj.module.sys.student.StudentEntity;
import com.yima.baseproj.module.sys.student.StudentService;
import com.yima.baseproj.module.sys.student.model.StudentSelectModel;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RequestMapping("/api/app/student")
@RestController
public class AppStudentController {

    @Autowired
    private StudentService studentService;


    @ApiOperation("根据班级id 查询学生列表")
    @GetMapping("/findAllByClassId/{classId}")
    public ResultVo findAllByClassId(@PathVariable int classId) {
        List<StudentSelectModel> studentList = studentService.findAllByClassId(classId);
        return ResultUtil.success(studentList);
    }

    @ApiOperation("根据学生id 查询学生信息")
    @GetMapping("/findStudentById/{id}")
    public ResultVo findStudentById(@PathVariable int id) {
        StudentSelectModel studentEntity = studentService.findStudentById(id);
        return ResultUtil.success(studentEntity);
    }


    @Logging(tags = "学生管理",value = "修改")
    @ApiOperation("修改")
    @PostMapping("/edit")
    public void editKg(@RequestBody @Validated StudentEntity customAdmin) {
        studentService.edit(customAdmin);
    }

}
